Skip to content

LDAP und htpasswd Authentifizierung

In diesem Beispiel möchten wir eine Kombination aus htpasswd und LDAP Authentifizierung erstellen um z.B. interne Benutzer über das Active Directory authentifizieren und externe Benutzer über htpasswd. Zuerst erstellen wir uns eine Datei conf-available/ldap-file_auth.conf in welcher wir einen AuthBasicProvider vom Typ file und ldap definieren.

<IfModule mod_authnz_ldap.c>
        AuthType Basic
        AuthBasicProvider file ldap
        AuthUserFile /etc/apache2/conf-available/htpasswd.txt
        AuthLDAPBindDN "<your bind dn>"
        AuthLDAPBindPassword "<your password>"
        AuthLDAPURL "ldap://<your domaincontroller>/DC=example,DC=com?sAMAccountName?sub"

        AuthLDAPGroupAttributeIsDN off
        AuthLDAPGroupAttribute memberUid
        Require valid-user
</IfModule>

Nun erstellen wir eine Datei conf-available/htpasswd.txt mit z.B. folgenden Inhalt. Das Passwort ist in diesem Fall Geheim123.

bubu:$apr1$iOIT38uF$mfpou6aEqupSUBxTHovQM0

In unserer V-Host Konfiguration können wir nun unser zu schützendes Verzeichnis wie folgt definieren.

<Location /svn>
    AuthName "File and LDAP authentification"
    Include "conf-available/ldap-file_auth.conf"
    Require ldap-group "CN=svn,OU=groups,DC=example,DC=com"
</Location>

In diese Konfiguration können nun alle Active Directory Benutzer der Gruppe svn und der Benutzer bubu aus der Datei conf-available/htpasswd.txt die Location /svn aufrufen.